package com.mipo.service;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mipo.dao.imp.MessageDAO;
import com.mipo.dao.imp.MessageDAOImp;
import com.mipo.dao.imp.MessageReceiveDAO;
import com.mipo.dao.imp.MessageReceiveDAOImp;
import com.mipo.vo.Message;
import com.mipo.vo.MessageReceive;

public class SeeMessageService extends HttpServlet {

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String mid = request.getParameter("mid");
		String rid = request.getParameter("rid");
		MessageReceiveDAO rdao = new MessageReceiveDAOImp();
		MessageReceive mr = new MessageReceive();
		mr.setRid(Integer.valueOf(rid));
		try {
			boolean b = rdao.updateMessageReceive(mr);

			if (b) {
				MessageDAO mdao = new MessageDAOImp();
				Message message = mdao.query(mid);
				
				request.setAttribute("mess", message);
				request.getRequestDispatcher("mess/seeMessage.jsp").forward(
						request, response);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
